#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
LL arr[N];
LL b[N];
int n, m;
int main()
{
	cin >> m >> n;
	for (int i = 1; i <= m; i++)cin >> arr[i];
	for (int i = 1; i <= n; i++)cin >> b[i];
	sort(arr + 1, arr + m + 1);
	LL ans = 0;
	for (int i = 1; i <= n; i++) {
		int l = 0, r = m + 1;
		while (l + 1 < r) {
			int mid = l + r >> 1;
			if (arr[mid] <= b[i])l = mid;
			else r = mid;
		}
		if (b[i] <= arr[1]) {
			ans += arr[1] - b[i];
		}
		else {
			ans += min(abs(arr[r] - b[i]), abs(b[i] - arr[r - 1]));
		}
		//cout << "r===" << r << endl;
		//if (arr[r] > b[i]) {
		//	if (r - 1 >= 1) {
		//		ans += min(arr[r] - b[i], b[i] - arr[r - 1]);
		//	}
		//	else {
		//		//cout << "111" << endl;
		//	}
		//}
		//else ans += b[i];
	}
	cout << ans << endl;
	return 0;
}